﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PSDLib.Models
{
    public class PSDState : IComparable<PSDState>
    {
        public string DeviceId { get; set; }

        public dl_download_device DeviceInfo { get; set; }

        public DateTime? LastHeertBeatTime { get; set; }

        private bool online = false;
        public bool Online
        {
            get { return online; }
            set
            {
                online = value;
                DeviceInfo.online = (online ? 1 : 0);
            }
        }

        public int CompareTo(PSDState other)
        {
            int ret = 0;

            if (this.Online && !other.Online)
            {
                ret = -1;
            }
            else if (!this.Online && other.Online)
            {
                ret = 1;
            }
            else
            {
                ret = this.DeviceInfo.device_name.CompareTo(other.DeviceInfo.device_name);
            }

            return ret;
        }
    }
}
